<?php
    include_once("../../service/productService.php");
    include_once("../../service/articleService.php");
    include_once("../../service/categoryService.php");
    if(isset($_POST["c"])){
?>
        <div class="breadcrumb">
            <a href='./index.php'><div class="breadcrumb-home-icon"></div></a>
            <?php
                getParentCate($_POST["c"]);
            ?>	
        </div>
<?php
    }else if(isset($_POST["p"])){
        $product = getProduct($_POST["p"]);
?>
        <div class="breadcrumb">
            <a href='./index.php'><div class="breadcrumb-home-icon"></div></a>
            <?php
                getParentCate($product["CAT_ID"]);
            ?>
            <?php
                echo "<div class='breadcrumb-sep'>".$product["PRO_NAME"]."</div>"; 
            ?>	
            <div class="alt">Xem thêm danh mục</div>
        </div>
<?php
    }else if(isset($_POST["a"])){
?>
        <div class="breadcrumb">
            <a href='./index.php'><div class="breadcrumb-home-icon"></div></a>
            <?php
                $abc = getPageOfArticle($_POST["a"]);
                echo "<div class='breadcrumb-sep'><a href='./news.php?page=".$abc["PAG_ID"]."'>".$abc["PAG_NAME"]."</a></div>";
                $article = getArticle($_POST["a"]);
                echo "<div class='breadcrumb-sep'>".$article["ART_TITLE"]."</div>"; 
            ?>
            <div class="alt">Xem thêm danh mục</div>	
        </div>
<?php
    }else if(isset($_POST["keyword"])){
?>
        <div class="breadcrumb">
            <a href='./index.php'><div class="breadcrumb-home-icon"></div></a>
            <?php                
                echo "<div class='breadcrumb-sep'>từ khoá tìm kiếm:".urldecode($_POST["keyword"])."</div>"; 
            ?>	
            <div class="alt">Xem thêm danh mục</div>
        </div>
<?php
    }else{
?>
    <div class="breadcrumb">
        <div class="breadcrumb-home-icon"></div>	
    </div>
<?php
    }
?>

<?php
    function getParentCate($cate_id){
        $cate = getCategory($cate_id);
        
        if($cate["CAT_PARENT_ID"] != 0){
            getParentCate($cate["CAT_PARENT_ID"]);
        }
        
        echo "<div class='breadcrumb-sep'><a href='./product.php?c=".$cate["CAT_ID"]."'>".$cate["CAT_NAME"]."</a></div>";
    }
?>
<script>
$("div.breadcrumb").find(".alt").click(function(e) {
	$('.toggleMenu').toggleClass("active");
	$(".menu").toggle();
});
</script>